package com.shiguo365.market.presenter.implement;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.shiguo365.market.display.view.IMarketPriceView;
import com.shiguo365.market.presenter.contract.IMarketPricePresenter;

import java.util.List;

import biz.yfsoft.app.aengine.api.AEClient;
import biz.yfsoft.app.aengine.api.BaseAECallback;

/**
 * Created by CoderA on 2016/7/9.
 */
public class MarketPricePresenter implements IMarketPricePresenter {

    private static final String TAG = "MarketPricePresenter";
    private final Activity mActivity;
    private final IMarketPriceView mView;

    public MarketPricePresenter(@NonNull Activity activity, @NonNull IMarketPriceView view) {
        this.mActivity = activity;
        this.mView = view;
    }


    @Override
    public void refreshProductList() {

        AEClient _client = new AEClient("shiguo.data.getProductList");
        _client.call(new BaseAECallback() {

            @Override
            public void onSuccess(List<JSONObject> a) {
                mView.onRefreshProductListResultOk(a);
            }

            @Override
            public void onError( String errno, String message) {
                Log.e(TAG,"onFailure ......." + errno + ";message:" + message);
            }

            @Override
            public void onFinally() {
                mView.onRefreshProductListFinish();
            }
        });
    }
}
